package com.wwc.sc.controller;

import com.wwc.sc.entities.Payment;
import com.wwc.sc.entities.result.CommonResult;
import com.wwc.sc.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author WWC
 */
@RestController
@Slf4j
@RequestMapping(value = "/consumer/payment")
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @RequestMapping(value = "/getPaymentById/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        CommonResult<Payment> payment = paymentFeignService.getPaymentById(id);
        return payment;
    }

    /**
     * 调用该方法 服务提供者会线程停止三秒钟 主要为了测试 openFeign 超时控制
     * @return
     */
    @RequestMapping(value = "/feign/timeout")
    public String paymentFeignTimeOut() {
        String serverPort = paymentFeignService.paymentFeignTimeOut();
        return serverPort;
    }

}
